#include "led.h"

volatile int i = 0x30313233;

void led_delay() {
  for (i = 6; i < 100000; i++) {
    asm("NOP");
  }
}
void led_init() {

  __HAL_RCC_GPIOB_CLK_ENABLE();
  GPIOB->MODER &= ~(0X03 << 4);
  GPIOB->MODER |= (0X01 << 4); // PB2->通用输出模式

  //GPIOB->OTYPER |= 0X0 << 2;   // PB2 推挽输出默认
  GPIOB->PUPDR |= (0X01 << 6); // PB2 上拉
}

void led_flash_loop() {
  led_init();
  while (1) {
    GPIOB->BSRR = 1 << 2 << 16; // reset PB2
    led_delay();
    GPIOB->BSRR = 1 << 2; // set PB2
    led_delay();
  }
}
